<template>
	<view class="search-box" :style="{backgroundColor}">
		<view class="u-flex" @click="chooseAddress">
			<text class="iconfont icon-dingwei"></text>
			<text>{{city}}</text>
		</view>
		<view class="divide"></view>
		<view class="u-flex-1">
			<input type="text" v-model="searchValue" placeholder-style="color:#B3B3B3" :placeholder="placeholder"
				:disabled="disabled" @click="seachTap" />
		</view>
		<view class="search-btn" v-if="showBtn">
			<u-button type="primary" shape="circle" size="mini" hover-class="none" @click="seachTap">搜索</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "bb-search",
		props: {
			placeholder: {
				type: String,
				default: "请搜索把关师、服务"
			},
			backgroundColor: {
				type: String,
				default: "#fff"
			},
			showBtn: {
				type: Boolean,
				default: true
			},
			city: {
				type: String,
				default: '定位中'
			},
			disabled: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				searchValue: ''
			};
		},
		methods: {
			chooseAddress() {
				this.$emit('toLocation')
			},
			seachTap() {
				this.$emit('seachTap')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.iconfont {
		color: #CCCCCC;
		margin: 0 13rpx;
	}

	.divide {
		height: 26rpx;
		width: 1px;
		background-color: #D9D9D9;
		margin: 0 20rpx;
	}

	.search-box {
		border-radius: 80rpx;
		display: flex;
		align-items: center;
		height: 80rpx;
		padding: 0 20rpx;
	}

	.search-btn {
		margin: 0 10rpx;
	}
</style>